import os
import json
import hashlib
import time

def getalldirs(path):
    dirs = os.listdir(path)
    return dirs


if __name__ == "__main__":
    path = "E:\\photo\\录像\\无时间"
    dirs = getalldirs(path)
    cmd = "winrar.exe a -k -r -s -ibck \"%s\" \"%s\""
    for dir in dirs:
        full_dir = path + "\\" + dir
        if os.path.isdir(full_dir):
            rar_file = full_dir + ".rar"
            cmd_copy = cmd % (rar_file, full_dir)
            os.system(cmd_copy)
            time.sleep(1)
    print("finished")
